package com.wsc.wisdomchina.ai.utils;

import android.database.Cursor;

import com.wsc.wisdomchina.ai.adapter.IBenDemoChatAdapter;
import com.wsc.wisdomchina.ai.db.DbManager;
import com.wsc.wisdomchina.ai.model.IBenDemoBean;

import java.util.List;

/**
 * Created by liuhaigang on 2016/12/19.
 */
public class DbUtils {
    public static void initChatData(List<IBenDemoBean> mMessageList, IBenDemoChatAdapter mListAdapter) {

        Cursor cursor = DbManager.selectChatData();
        if (cursor == null) {
            return;
        }
        mMessageList.clear();
        while (cursor.moveToNext()) {
            IBenDemoBean bean = new IBenDemoBean();
            int type_user = cursor.getInt(cursor.getColumnIndex("type_user"));
            int type_message = cursor.getInt(cursor.getColumnIndex("type_message"));
            float time_voice = cursor.getFloat(cursor.getColumnIndex("time_voice"));
            String content_text = cursor.getString(cursor.getColumnIndex("content_text"));
            String path = cursor.getString(cursor.getColumnIndex("path"));
            String richtitle = cursor.getString(cursor.getColumnIndex("richtitle"));
            String richImgpath = cursor.getString(cursor.getColumnIndex("richImgpath"));
            String richDesc = cursor.getString(cursor.getColumnIndex("richDesc"));
            String times = cursor.getString(cursor.getColumnIndex("times"));
            bean.setType(type_user);
            bean.setAnswerType(type_message);
            bean.setRichTitle(richtitle);
            bean.setRichImg(richImgpath);
            bean.setRichDesc(richDesc);
            bean.setTime(time_voice);
            bean.setContent(content_text);
            bean.setFilePathString(path);
            mMessageList.add(bean);
            mListAdapter.updateList(mMessageList);
        }
//        switch (chatTo) {
//            case "IB":
//                Cursor cursor = DbManager.selectChatData();
//                if (cursor == null) {
//                    return;
//                }
//                mMessageList.clear();
//                while (cursor.moveToNext()) {
//                    IBenDemoBean bean = new IBenDemoBean();
//                    int type_user = cursor.getInt(cursor.getColumnIndex("type_user"));
//                    int type_message = cursor.getInt(cursor.getColumnIndex("type_message"));
//                    int time_voice = cursor.getInt(cursor.getColumnIndex("time_voice"));
//                    String content_text = cursor.getString(cursor.getColumnIndex("content_text"));
//                    String path = cursor.getString(cursor.getColumnIndex("path"));
//                    String richtitle = cursor.getString(cursor.getColumnIndex("richtitle"));
//                    String richImgpath = cursor.getString(cursor.getColumnIndex("richImgpath"));
//                    String richDesc = cursor.getString(cursor.getColumnIndex("richDesc"));
//                    String times = cursor.getString(cursor.getColumnIndex("times"));
//                    bean.setType(type_user);
//                    bean.setAnswerType(type_message);
//                    bean.setRichTitle(richtitle);
//                    bean.setRichImg(richImgpath);
//                    bean.setRichDesc(richDesc);
//                    bean.setTime(time_voice);
//                    bean.setContent(content_text);
//                    bean.setFilePathString(path);
//                    mMessageList.add(bean);
//                    mListAdapter.updateList(mMessageList);
//                }
//                break;
//            case "CS":
//                Cursor cursor1 = DbManager.selectCS();
//                if (cursor1 == null) {
//                    return;
//                }
//                mMessageList.clear();
//                while (cursor1.moveToNext()) {
//                    IBenDemoBean bean = new IBenDemoBean();
////                    values.put("type_user", typeUser);
////                    values.put("type_message", typeMessage);
////                    values.put("content_text", contextText);
////                    values.put("path", path);
////                    values.put("time_voice", timeVoice);
////                    values.put("times", times);
//                    int type_user = cursor1.getInt(cursor1.getColumnIndex("type_user"));
//                    int type_message = cursor1.getInt(cursor1.getColumnIndex("type_message"));
//                    int time_voice = cursor1.getInt(cursor1.getColumnIndex("time_voice"));
//                    String content_text = cursor1.getString(cursor1.getColumnIndex("content_text"));
//                    String path = cursor1.getString(cursor1.getColumnIndex("path"));
//                    String times = cursor1.getString(cursor1.getColumnIndex("times"));
//                    bean.setType(type_user);
//                    bean.setAnswerType(type_message);
//                    bean.setTime(time_voice);
//                    bean.setFilePathString(path);
//                    bean.setContent(content_text);
//
//                    mMessageList.add(bean);
//                    mListAdapter.updateList(mMessageList);
//                }
//                break;
//
//        }
    }
}
